package com.mysoft.gfyx.clue.service.impl;

import com.mysoft.gfyx.clue.dao.MessageInboxDao;
import com.mysoft.gfyx.clue.dao.entity.MessageInbox;
import com.mysoft.gfyx.clue.service.MessageInboxService;
import com.mysoft.gfyx.clue.service.dto.MessageInboxDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Slf4j
@Service
public class MessageInboxServiceImp implements MessageInboxService {
    @Autowired
    private MessageInboxDao messageInboxDao;

    @Override
    public void AddMessage(MessageInboxDto dto) {
        Date currentTime = new Date();
        MessageInbox entity = new MessageInbox();
        entity.setMessageType(dto.getMessageType());
        entity.setTitle(dto.getContent());
        entity.setContent(dto.getContent());
        entity.setSenderId(dto.getSenderId());
        entity.setReceiverId(dto.getReceiverId());
        entity.setReadedTime(null);
        // 2 未读
        entity.setIsReaded(2);
        entity.setReceivedTime(currentTime);
        entity.setLink(dto.getLink());
        entity.setCreatedBy("");
        entity.setCreatedOn(currentTime);
        entity.setModifiedBy("");
        entity.setModifiedOn(currentTime);
        entity.setIsDeleted(0);
        messageInboxDao.insert(entity);
    }
}
